package com.authine.cloudpivot.ext.applicationservice.v1.sourcing;

/*import com.authine.cloudpivot.ext.applicationservice.v1.sourcing.vo.HbRequestModel;*/


/*@Slf4j
public class HuaBaoService extends ApplicationService {

    *//**
     * 推送华宝报价
     * @param inquiryDto
     * @return
     * @throws
     * @author zhanjh
     * @date 2021/10/29 10:49
     *//*
    public void pushQuotationGoodsToHb(@Parameter InquiryDto inquiryDto) {

        //查询询价单id集合
        SingleResponse<BOList> inquiryGoodsBOList = BoServiceUtils.findListBySimple(ModelConst.T_INQUIRY_GOODS, "inquiry_id", inquiryDto.getInquiryId());
        log.info("----------------------inquiryGoodsBOList：{}------------------------", JSONObject.toJSONString(inquiryGoodsBOList));


        inquiryGoodsBOList.getData().getData().forEach(i -> {
            // 报价明细
            List<HbRequestModel.PriceLines> priceLinesList = new ArrayList<>();
            String[] columns = new String[]{"inquiry_goods_id", "client_id"};
            Operator[] operators = new Operator[]{Operator.EQ, Operator.EQ};
            Object[] columnsVal = new Object[]{i.get("id"), "hb_api"};
            SingleResponse<BOList> quotationGoodsList = BoServiceUtils.findListByComplex(ModelConst.T_QUOTATION_GOODS, columns, columnsVal, operators);
            log.info("------------------------根据询价商品id和clientId查询报价商品表，quotationGoodsList：{}------------------------", JSONObject.toJSONString(quotationGoodsList));
            if (CollectionUtils.isEmpty(quotationGoodsList.getData().getData())) {
                return;
            }
            SingleResponse<BOList> inquiryMap = BoServiceUtils.findListBySimple(ModelConst.T_INQUIRY, "id", i.get("inquiry_id"));
            quotationGoodsList.getData().getData().forEach(q -> {
                HbRequestModel.PriceLines priceLines = HbRequestModel.PriceLines.builder()
                        .quotationGoodsId(null == q.get("id")?null:String.valueOf(q.get("id")))
                        .clientInquiryGoodsId(null == q.get("inquiry_goods_id")?null:q.get("inquiry_goods_id").toString())
                        .price(null == q.get("price")?null:Double.parseDouble(q.get("price").toString()))
                        .num(null == q.get("num")?null:Double.parseDouble(q.get("num").toString()))
                        .name(null == q.get("name")?null:q.get("name").toString())
                        .model(null == q.get("model")?null:q.get("model").toString())
                        .unit(null == q.get("unit")?null:q.get("unit").toString())
                        .vendorName(null == q.get("vendor_organization_name")?null:q.get("vendor_organization_name").toString())
                        .delivery(null == q.get("delivery")?null:String.valueOf(q.get("delivery")))
                        .memo(null == q.get("description")?null:q.get("description").toString())
                        .build();
                priceLinesList.add(priceLines);
            });
            HbRequestModel hbQuotationModel = HbRequestModel.getPushHbQuotationModel().builder()
                    .applicantId(null == inquiryMap.getData().getData().get(0).get("client_user_id")?null:
                            inquiryMap.getData().getData().get(0).get("client_user_id").toString())
                    .priceLines(priceLinesList).build();
            log.warn("[pushQuotationGoodsToHuaBao] -- 推送{}条报价数据--->华宝,报价信息:{}", priceLinesList.size(), hbQuotationModel);

            try {
                String restResponse = pushQuotationGoodsToHb(hbQuotationModel);
                log.warn("[punchoutApi.pushQuotationToHb] -- return:{}", restResponse);
            } catch (Exception e) {
                log.error("推送报价数据给华宝异常，error is :", e);
            }
        });
    }


    *//**
     * 推送华宝报价信息
     * @param hbRequestModel
     * @return
     * @Author zhanjh
     *//*
    public String pushQuotationGoodsToHb(HbRequestModel hbRequestModel){
        log.warn("推送华宝报价信息：{}", hbRequestModel);
        // 报价列表
        List<HbRequestModel.PriceLines> priceLines = hbRequestModel.getPriceLines();
        // 根据金额排序
        priceLines  = priceLines.stream().sorted(Comparator.comparing(HbRequestModel.PriceLines::getPrice)).collect(Collectors.toList());

        ObjectFactory factory = new ObjectFactory();
        WorkflowService service = new WorkflowService();
        // 申请人ID \部门ID \公司ID fixme 这里和客户确认过 就这么干
        String client = hbRequestModel.getApplicantId();
        List<String> clientList = Arrays.asList(client.split(" "));
        String clientUserId = clientList.get(0);
        String clientDepartmentId = clientList.get(1);
        String clientOrganizationId = clientList.get(2);

        WorkflowRequestInfo workflowRequestInfo = new WorkflowRequestInfo(); //工作流程请求信息
        //workflowRequestInfo.setRequestId(factory.createWorkflowRequestInfoRequestName("50120")); //流程请求ID-创建流程时自动产生
        workflowRequestInfo.setCanView(true);//显示
        workflowRequestInfo.setCanEdit(true);//可编辑
        workflowRequestInfo.setRequestName(factory.createWorkflowRequestInfoRequestName("报价信息推送"));//请求标题
        workflowRequestInfo.setRequestLevel(factory.createWorkflowRequestInfoRequestLevel("0"));
        workflowRequestInfo.setCreatorId(factory.createWorkflowRequestInfoCreatorId(clientUserId));

        WorkflowBaseInfo workflowBaseInfo = new WorkflowBaseInfo();//工作流信息
        //流程ID 测试：37621 生产：50120
        workflowBaseInfo.setWorkflowId(factory.createWorkflowBaseInfoWorkflowId("50120"));
        workflowBaseInfo.setWorkflowName(factory.createWorkflowBaseInfoWorkflowName("webservice-test"));//工作流信息
        // workflowBaseInfo.setWorkflowTypeId("1951");
        // workflowBaseInfo.setWorkflowTypeName(factory.createWorkflowBaseInfoWorkflowTypeName("webservice-test"));
        workflowRequestInfo.setWorkflowBaseInfo(factory.createWorkflowRequestInfoWorkflowBaseInfo(workflowBaseInfo));

        //****************main table start*************
        WorkflowMainTableInfo workflowMainTableInfo = new WorkflowMainTableInfo();//主表
        WorkflowRequestTableRecord[] workflowRequestTableRecord = new WorkflowRequestTableRecord[1];//主表字段只有一条记录
        WorkflowRequestTableField[] WorkflowRequestTableField = new WorkflowRequestTableField[3];//主的1个字段

        WorkflowRequestTableField[0] = new WorkflowRequestTableField();
        WorkflowRequestTableField[0].setFieldName(factory.createWorkflowRequestTableFieldFieldName("contacts"));// 申请人ID
        WorkflowRequestTableField[0].setFieldValue(factory.createWorkflowRequestTableFieldFieldValue(clientUserId));
        WorkflowRequestTableField[0].setView(true);
        WorkflowRequestTableField[0].setEdit(true);

        WorkflowRequestTableField[1] = new WorkflowRequestTableField();
        WorkflowRequestTableField[1].setFieldName(factory.createWorkflowRequestTableFieldFieldName("sqbm"));// 部门ID
        WorkflowRequestTableField[1].setFieldValue(factory.createWorkflowRequestTableFieldFieldValue(clientDepartmentId));
        WorkflowRequestTableField[1].setView(true);
        WorkflowRequestTableField[1].setEdit(true);

        WorkflowRequestTableField[2] = new WorkflowRequestTableField();
        WorkflowRequestTableField[2].setFieldName(factory.createWorkflowRequestTableFieldFieldName("qq"));// 公司ID
        WorkflowRequestTableField[2].setFieldValue(factory.createWorkflowRequestTableFieldFieldValue(clientOrganizationId));
        WorkflowRequestTableField[2].setView(true);
        WorkflowRequestTableField[2].setEdit(true);

        workflowRequestTableRecord[0] = new WorkflowRequestTableRecord();
        ArrayOfWorkflowRequestTableField arrayOfWorkflowRequestTableField = new ArrayOfWorkflowRequestTableField();
        arrayOfWorkflowRequestTableField.getWorkflowRequestTableField().add(WorkflowRequestTableField[0]);
        arrayOfWorkflowRequestTableField.getWorkflowRequestTableField().add(WorkflowRequestTableField[1]);
        arrayOfWorkflowRequestTableField.getWorkflowRequestTableField().add(WorkflowRequestTableField[2]);
        WorkflowRequestTableRecord workflowRequestTableRecord1 = new WorkflowRequestTableRecord();

        workflowRequestTableRecord1.setWorkflowRequestTableFields(factory.createWorkflowRequestTableRecordWorkflowRequestTableFields(arrayOfWorkflowRequestTableField));
        ArrayOfWorkflowRequestTableRecord arrayOfWorkflowRequestTableRecord = new ArrayOfWorkflowRequestTableRecord();
        arrayOfWorkflowRequestTableRecord.getWorkflowRequestTableRecord().add(workflowRequestTableRecord1);
        workflowMainTableInfo.setRequestRecords(factory.createWorkflowMainTableInfoRequestRecords(arrayOfWorkflowRequestTableRecord));
        workflowRequestInfo.setWorkflowMainTableInfo(factory.createWorkflowRequestInfoWorkflowMainTableInfo(workflowMainTableInfo));
        //****************main table end*************


        //****************detail table start*************
        // 明细表
        WorkflowDetailTableInfo[] workflowDetailTableInfo = new WorkflowDetailTableInfo[2];
        //**********明细表开始**********
        //一行数据（一条记录）
        List<WorkflowRequestTableRecord> list = new ArrayList<>();
        priceLines.forEach(t -> {
            WorkflowRequestTableRecord workflowRequestTableRecord0 = new WorkflowRequestTableRecord();
            WorkflowRequestTableField[] WorkflowRequestTableField0 = new WorkflowRequestTableField[11];// 每行12个字段

            //****第一行开始****
            WorkflowRequestTableField0[0] = new WorkflowRequestTableField();
            WorkflowRequestTableField0[0].setFieldName(factory.createWorkflowRequestTableFieldFieldName("wybs"));// 唯一标识
            WorkflowRequestTableField0[0].setFieldValue(factory.createWorkflowRequestTableFieldFieldValue(t.getQuotationGoodsId()));
            WorkflowRequestTableField0[0].setView(true);
            WorkflowRequestTableField0[0].setEdit(true);

            WorkflowRequestTableField0[1] = new WorkflowRequestTableField();
            WorkflowRequestTableField0[1].setFieldName(factory.createWorkflowRequestTableFieldFieldName("clientInquiryGoodsId"));// 唯一标识
            WorkflowRequestTableField0[1].setFieldValue(factory.createWorkflowRequestTableFieldFieldValue(t.getClientInquiryGoodsId()));
            WorkflowRequestTableField0[1].setView(true);
            WorkflowRequestTableField0[1].setEdit(true);

            WorkflowRequestTableField0[2] = new WorkflowRequestTableField();
            WorkflowRequestTableField0[2].setFieldName(factory.createWorkflowRequestTableFieldFieldName("name"));// 物料名称
            WorkflowRequestTableField0[2].setFieldValue(factory.createWorkflowRequestTableFieldFieldValue(t.getName()));
            WorkflowRequestTableField0[2].setView(true);
            WorkflowRequestTableField0[2].setEdit(true);

            WorkflowRequestTableField0[3] = new WorkflowRequestTableField();
            WorkflowRequestTableField0[3].setFieldName(factory.createWorkflowRequestTableFieldFieldName("model"));// 规格型号
            WorkflowRequestTableField0[3].setFieldValue(factory.createWorkflowRequestTableFieldFieldValue(t.getModel()));
            WorkflowRequestTableField0[3].setView(true);
            WorkflowRequestTableField0[3].setEdit(true);

            WorkflowRequestTableField0[4] = new WorkflowRequestTableField();
            WorkflowRequestTableField0[4].setFieldName(factory.createWorkflowRequestTableFieldFieldName("unit"));// 单位
            WorkflowRequestTableField0[4].setFieldValue(factory.createWorkflowRequestTableFieldFieldValue(t.getUnit()));
            WorkflowRequestTableField0[4].setView(true);
            WorkflowRequestTableField0[4].setEdit(true);

            WorkflowRequestTableField0[5] = new WorkflowRequestTableField();
            WorkflowRequestTableField0[5].setFieldName(factory.createWorkflowRequestTableFieldFieldName("num"));// 数量
            WorkflowRequestTableField0[5].setFieldValue(factory.createWorkflowRequestTableFieldFieldValue(String.valueOf(t.getNum())));
            WorkflowRequestTableField0[5].setView(true);
            WorkflowRequestTableField0[5].setEdit(true);

            WorkflowRequestTableField0[6] = new WorkflowRequestTableField();
            WorkflowRequestTableField0[6].setFieldName(factory.createWorkflowRequestTableFieldFieldName("ghs"));// 供货商
            WorkflowRequestTableField0[6].setFieldValue(factory.createWorkflowRequestTableFieldFieldValue(t.getVendorName()));
            WorkflowRequestTableField0[6].setView(true);
            WorkflowRequestTableField0[6].setEdit(true);

            WorkflowRequestTableField0[7] = new WorkflowRequestTableField();
            WorkflowRequestTableField0[7].setFieldName(factory.createWorkflowRequestTableFieldFieldName("dj"));// 单价
            WorkflowRequestTableField0[7].setFieldValue(factory.createWorkflowRequestTableFieldFieldValue(String.valueOf(t.getPrice())));
            WorkflowRequestTableField0[7].setView(true);
            WorkflowRequestTableField0[7].setEdit(true);

            WorkflowRequestTableField0[8] = new WorkflowRequestTableField();
            WorkflowRequestTableField0[8].setFieldName(factory.createWorkflowRequestTableFieldFieldName("xj"));// 小计
            WorkflowRequestTableField0[8].setFieldValue(factory.createWorkflowRequestTableFieldFieldValue(String.valueOf(BigDecimalUtils.mul(t.getNum(), t.getPrice()))));
            WorkflowRequestTableField0[8].setView(true);
            WorkflowRequestTableField0[8].setEdit(true);

            WorkflowRequestTableField0[9] = new WorkflowRequestTableField();
            WorkflowRequestTableField0[9].setFieldName(factory.createWorkflowRequestTableFieldFieldName("delivery"));// 账期
            WorkflowRequestTableField0[9].setFieldValue(factory.createWorkflowRequestTableFieldFieldValue(t.getDelivery()));
            WorkflowRequestTableField0[9].setView(true);
            WorkflowRequestTableField0[9].setEdit(true);

            WorkflowRequestTableField0[10] = new WorkflowRequestTableField();
            WorkflowRequestTableField0[10].setFieldName(factory.createWorkflowRequestTableFieldFieldName("memo"));// 供应商备注
            WorkflowRequestTableField0[10].setFieldValue(factory.createWorkflowRequestTableFieldFieldValue(t.getMemo()));
            WorkflowRequestTableField0[10].setView(true);
            WorkflowRequestTableField0[10].setEdit(true);

            ArrayOfWorkflowRequestTableField arrayOfWorkflowRequestTableField1 = new ArrayOfWorkflowRequestTableField();
            arrayOfWorkflowRequestTableField1.getWorkflowRequestTableField().add(WorkflowRequestTableField0[0]);
            arrayOfWorkflowRequestTableField1.getWorkflowRequestTableField().add(WorkflowRequestTableField0[1]);
            arrayOfWorkflowRequestTableField1.getWorkflowRequestTableField().add(WorkflowRequestTableField0[2]);
            arrayOfWorkflowRequestTableField1.getWorkflowRequestTableField().add(WorkflowRequestTableField0[3]);
            arrayOfWorkflowRequestTableField1.getWorkflowRequestTableField().add(WorkflowRequestTableField0[4]);
            arrayOfWorkflowRequestTableField1.getWorkflowRequestTableField().add(WorkflowRequestTableField0[5]);
            arrayOfWorkflowRequestTableField1.getWorkflowRequestTableField().add(WorkflowRequestTableField0[6]);
            arrayOfWorkflowRequestTableField1.getWorkflowRequestTableField().add(WorkflowRequestTableField0[7]);
            arrayOfWorkflowRequestTableField1.getWorkflowRequestTableField().add(WorkflowRequestTableField0[8]);
            arrayOfWorkflowRequestTableField1.getWorkflowRequestTableField().add(WorkflowRequestTableField0[9]);
            arrayOfWorkflowRequestTableField1.getWorkflowRequestTableField().add(WorkflowRequestTableField0[10]);
            workflowRequestTableRecord0.setWorkflowRequestTableFields(factory.createWorkflowRequestTableRecordWorkflowRequestTableFields(arrayOfWorkflowRequestTableField1));
            list.add(workflowRequestTableRecord0);
            //****第一行结束****
        });


        // 第一张明细表
        workflowDetailTableInfo[0] = new WorkflowDetailTableInfo();
        ArrayOfWorkflowRequestTableRecord arrayOfWorkflowRequestTableRecord0 = new ArrayOfWorkflowRequestTableRecord();
        workflowDetailTableInfo[0].setWorkflowRequestTableRecords(factory.createWorkflowDetailTableInfoWorkflowRequestTableRecords(arrayOfWorkflowRequestTableRecord0));


        // 第二张明细表
        workflowDetailTableInfo[1] = new WorkflowDetailTableInfo();
        ArrayOfWorkflowRequestTableRecord arrayOfWorkflowRequestTableRecord1 = new ArrayOfWorkflowRequestTableRecord();
        list.forEach(t -> arrayOfWorkflowRequestTableRecord1.getWorkflowRequestTableRecord().add(t));
        workflowDetailTableInfo[1].setWorkflowRequestTableRecords(factory.createWorkflowDetailTableInfoWorkflowRequestTableRecords(arrayOfWorkflowRequestTableRecord1));
        //**********明细表结束**********

        //		workflowDetailTableInfo[0].setWorkflowRequestTableRecords(factory.createWorkflowDetailTableInfoWorkflowRequestTableRecords(arrayOfWorkflowRequestTableRecord2));

        ArrayOfWorkflowDetailTableInfo arrayOfWorkflowDetailTableInfo = new ArrayOfWorkflowDetailTableInfo();
        arrayOfWorkflowDetailTableInfo.getWorkflowDetailTableInfo().add(workflowDetailTableInfo[0]);
        arrayOfWorkflowDetailTableInfo.getWorkflowDetailTableInfo().add(workflowDetailTableInfo[1]);
        workflowRequestInfo.setWorkflowDetailTableInfos(factory.createWorkflowRequestInfoWorkflowDetailTableInfos(arrayOfWorkflowDetailTableInfo));

        //****************detail table end*************
        String response = service.getWorkflowServiceHttpPort().doCreateWorkflowRequest(workflowRequestInfo, Integer.parseInt(clientUserId));
        log.warn("请求华宝接口返回：{}", response);
        return response;
    }
}*/
